using System;
using System.Collections.Generic;
using System.Linq;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using System.ComponentModel.DataAnnotations;
using HengTong.Model.Db.Hr.Attendance;


namespace HengTong.ViewModel.Hr.SysAttendanceShiftAndGroupVms
{
    public partial class SysAttendanceShiftAndGroupListVm : BaseListVm<SysAttendanceShiftAndGroupView, SysAttendanceShiftAndGroupSearcher>
    {

        protected override IEnumerable<IGridColumn<SysAttendanceShiftAndGroupView>> InitGridHeader()
        {
            return new List<GridColumn<SysAttendanceShiftAndGroupView>>{
                this.MakeGridHeader(x => x.ShiftName),
                this.MakeGridHeader(x => x.GroupName),
                this.MakeGridHeader(x => x.Tag),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysAttendanceShiftAndGroupView> GetSearchQuery()
        {
            var query = DC.Set<SysAttendanceShiftAndGroup>()
                .CheckEqual(Searcher.ShiftId, x=>x.ShiftId)
                .CheckEqual(Searcher.GroupId, x=>x.GroupId)
                .CheckEqual(Searcher.Tag, x=>x.Tag)
                .Select(x => new SysAttendanceShiftAndGroupView
                {
				    ID = x.ID,
                    ShiftName = x.Shift.Name,
                    GroupName = x.Group.Name,
                    Tag = x.Tag,
                })
                .OrderBy(x => x.ID);
            return query;
        }
    }

    public class SysAttendanceShiftAndGroupView : SysAttendanceShiftAndGroup{
        [Display(Name = "班次名称")]
        public String ShiftName { get; set; }
        [Display(Name = "班组名称")]
        public String GroupName { get; set; }

    }
}
